package com.dailyblue.java.spring.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

//@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        String user = "zhangsan";
        String password = "123456";
        BCryptPasswordEncoder encoder = getBCP();
        // 加密
        password = encoder.encode(password);
        auth.inMemoryAuthentication().withUser(user).password(password).roles("aaa");

    }

    //@Bean
    BCryptPasswordEncoder getBCP() {
        return new BCryptPasswordEncoder();
    }
}
